//using BasicScript;
//using Game.Core;
//using UnityEngine;
//using UnityEngine.Purchasing;
//using UnityEngine.Purchasing.Security;

namespace Game.Manager
{
	//public class PurchasingManager : Singleton<PurchasingManager>, IStoreListener
	//{
	//	public static string UNLOCK_ALL = "com.miga.myhospital.1";

	//	public string unlockAllPrice;

	//	private IStoreController controller;

	//	private IExtensionProvider storeExtensions;

	//	private Product unlockPuzzleProduct;

	//	private CrossPlatformValidator validator;

	//	private string appIdentifier;

	//	public PurchasingManager()
	//	{
	//		unlockAllPrice = Singleton<SaveManager>.Instance.price1;
	//		StandardPurchasingModule first = StandardPurchasingModule.Instance();
	//		ConfigurationBuilder configurationBuilder = ConfigurationBuilder.Instance(first);
	//		configurationBuilder.AddProduct(UNLOCK_ALL, ProductType.NonConsumable);
	//		appIdentifier = Application.identifier;
	//		validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), UnityChannelTangle.Data(), appIdentifier);
	//		UnityPurchasing.Initialize(this, configurationBuilder);
	//	}

	//	public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
	//	{
	//		this.controller = controller;
	//		storeExtensions = extensions;
	//		unlockPuzzleProduct = this.controller.products.WithID(UNLOCK_ALL);
	//		if (unlockPuzzleProduct != null)
	//		{
	//			unlockAllPrice = unlockPuzzleProduct.metadata.localizedPriceString;
	//			Singleton<SaveManager>.Instance.price1 = unlockAllPrice;
	//		}
	//	}

	//	public void RestorePurchases()
	//	{
	//		if (storeExtensions == null)
	//		{
	//			Debug.Log("恢复购买失败，插件未初始化");
	//		}
	//		else if (ClientConfig.PLATFORM == PlatformType.IOS)
	//		{
	//			IAppleExtensions extension = storeExtensions.GetExtension<IAppleExtensions>();
	//			extension.RestoreTransactions(delegate
	//			{
	//			});
	//		}
	//	}

	//	public void OnInitializeFailed(InitializationFailureReason error)
	//	{
	//	}

	//	public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
	//	{
	//		if (ClientConfig.PLATFORM == PlatformType.IOS)
	//		{
	//			try
	//			{
	//				IPurchaseReceipt[] array = validator.Validate(e.purchasedProduct.receipt);
	//				Debug.Log("Receipt is valid. Contents:");
	//				IPurchaseReceipt[] array2 = array;
	//				foreach (IPurchaseReceipt purchaseReceipt in array2)
	//				{
	//					Debug.Log(purchaseReceipt.productID);
	//					Debug.Log(purchaseReceipt.purchaseDate);
	//					Debug.Log(purchaseReceipt.transactionID);
	//					GooglePlayReceipt googlePlayReceipt = purchaseReceipt as GooglePlayReceipt;
	//					if (googlePlayReceipt != null)
	//					{
	//						Debug.Log(googlePlayReceipt.purchaseState);
	//						Debug.Log(googlePlayReceipt.purchaseToken);
	//						GlobalEventSystem.Fire(new BaseEvent("game.purchasing_result", true));
	//						return PurchaseProcessingResult.Complete;
	//					}
	//					UnityChannelReceipt unityChannelReceipt = purchaseReceipt as UnityChannelReceipt;
	//					if (unityChannelReceipt != null)
	//					{
	//						Debug.Log(unityChannelReceipt.productID);
	//						Debug.Log(unityChannelReceipt.purchaseDate);
	//						Debug.Log(unityChannelReceipt.transactionID);
	//						GlobalEventSystem.Fire(new BaseEvent("game.purchasing_result", true));
	//						return PurchaseProcessingResult.Complete;
	//					}
	//					AppleInAppPurchaseReceipt appleInAppPurchaseReceipt = purchaseReceipt as AppleInAppPurchaseReceipt;
	//					if (appleInAppPurchaseReceipt != null)
	//					{
	//						Debug.Log(appleInAppPurchaseReceipt.originalTransactionIdentifier);
	//						Debug.Log(appleInAppPurchaseReceipt.subscriptionExpirationDate);
	//						Debug.Log(appleInAppPurchaseReceipt.cancellationDate);
	//						Debug.Log(appleInAppPurchaseReceipt.quantity);
	//						GlobalEventSystem.Fire(new BaseEvent("game.purchasing_result", true));
	//						return PurchaseProcessingResult.Complete;
	//					}
	//				}
	//			}
	//			catch (IAPSecurityException ex)
	//			{
	//				GlobalEventSystem.Fire(new BaseEvent("game.purchasing_result", false));
	//				Debug.Log("Invalid receipt, not unlocking content. " + ex);
	//				return PurchaseProcessingResult.Complete;
	//			}
	//		}
	//		else
	//		{
	//			GlobalEventSystem.Fire(new BaseEvent("game.purchasing_result", true));
	//		}
	//		return PurchaseProcessingResult.Complete;
	//	}

	//	public void OnPurchaseFailed(Product item, PurchaseFailureReason r)
	//	{
	//		GlobalEventSystem.Fire(new BaseEvent("game.purchasing_result", false));
	//	}

	//	public void InitiatePurchase(string productId)
	//	{
	//		if (controller != null)
	//		{
	//			controller.InitiatePurchase(productId);
	//		}
	//		else
	//		{
	//			Debug.Log("购买失败，插件未初始化");
	//		}
	//	}
	//}
}
